home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 5
/
Apprentice-Release5.iso
/
Source Code
/
C++
/
Applications
/
PICSee Dust 1.01
/
Quaternary Source
/
ReadPicture.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-11-01
|
905b
|
48 lines
#include "ReadPicture.h"
PicHandle ReadPicture(FSSpec *pictFile) {
PicHandle thePic;
short fileRefNum;
OSErr myErr;
long picSize;
myErr = FSpOpenDF(pictFile, fsCurPerm, &fileRefNum);
if (myErr != noErr) {
SysBeep(10);
return(NULL);
}
myErr = GetEOF(fileRefNum, &picSize);
if (myErr != noErr) {
SysBeep(10);
return(NULL);
}
picSize -= 512; // Don't include pict file header data
thePic = (PicHandle)NewHandle(picSize);
if (thePic == NULL)
return(NULL);
HNoPurge((Handle)thePic);
myErr = SetFPos(fileRefNum, fsFromStart, 512);
if (myErr != noErr) {
SysBeep(10);
return(NULL);
}
HLock((Handle)thePic);
myErr = FSRead(fileRefNum, &picSize, (Ptr)*thePic);
if (myErr != noErr) {
SysBeep(10);
return(NULL);
}
HUnlock((Handle)thePic);
myErr = FSClose(fileRefNum);
if (myErr != noErr) {
SysBeep(10);
return(NULL);
}
return(thePic);
} // END ReadPicture